import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from "@/routers/index";
import { useCounterStore } from '@/stores/counter'
import pinia from './stores/index'
import axios from './utils/axios'
import mitt from 'mitt';
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/reset.css';
// import { ConfigProvider } from 'ant-design-vue';
// import {
//     renderWithQiankun,
//     qiankunWindow
// } from 'vite-plugin-qiankun/dist/helper';

// let instance: any = null;

// async function render(props: any = {}) {
//     const { container, activeRule } =
//         props;

//     instance = createApp(App);
//     instance.use(router);
//     instance?.mount(container ? container.querySelector("#app") : "#app");
//     instance.config.globalProperties.$activeRule = activeRule;
// }

// const initQianKun = () => {
//     renderWithQiankun({
//         mount(props) {
//             render(props);
//         },
//         bootstrap() { },
//         update() { },
//         unmount() {
//             instance.unmount();
//             instance._container.innerHTML = "";
//             instance = null;
//             history.destroy();
//         },
//     });
// };

// if (qiankunWindow.__POWERED_BY_QIANKUN__) {
//     console.log("qiankun渲染开始");
//     initQianKun();
// } else {
//     console.log("不是qiankun渲染");
//     render();
// }
const app = createApp(App)
const store = useCounterStore()
app.config.globalProperties.$api = axios
app.config.globalProperties.$store = store
app.config.globalProperties.$fn = mitt()

app.use(pinia)
app.use(router)
app.use(Antd)
// app.component('a-config-provider', ConfigProvider); // 全局注册 ConfigProvider 组件（可选）

app.mount('#app')